{% set pypi_name = 'pycadf' %}
{% set upstream_version = upstream_version('3.1.1') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        DMTF Cloud Audit (CADF) data model
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/pycadf
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('oslo.config') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
DMTF Cloud Audit (CADF) data model

%package -n {{ py2name(py_versions='py3') }}
Summary:        DMTF Cloud Audit (CADF) data model
Requires:       python-pycadf-common
Requires:       {{ py3('debtcollector') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('pytz') }}
Requires:       {{ py3('six') }}

%description -n {{ py2name(py_versions='py3') }}
DMTF Cloud Audit (CADF) data model

This package contains the Python 3.x module.

%package -n python-pycadf-doc
Summary:        Documentation for the DMTF Cloud Audit (CADF) data model
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-apidoc') }}

%description -n python-pycadf-doc
Documentation for the DMTF Cloud Audit (CADF) data model.

%package -n python-pycadf-common
Summary:        Common files for the DMTF Cloud Audit (CADF) data model

%description -n python-pycadf-common
Configuration files for the DMTF Cloud Audit (CADF) data model.

%prep
%autosetup -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

# generate html docs
PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}
# FIXME: pbr/wheel bug installing onfiguration files in /usr/etc
mkdir -p %{buildroot}/%{_sysconfdir}
mv %{buildroot}%{_prefix}%{_sysconfdir}/{{ pypi_name }} %{buildroot}/%{_sysconfdir}/

%check
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%doc README.rst
%license LICENSE
%{python3_sitelib}/{{ pypi_name }}
%{python3_sitelib}/{{ pypi_name }}-*-py?.?.egg-info

%files -n python-pycadf-common
%license LICENSE
%dir %{_sysconfdir}/{{ pypi_name }}
%config(noreplace) %{_sysconfdir}/{{ pypi_name }}/*.conf

%files -n python-pycadf-doc
%license LICENSE
%doc doc/build/html

%changelog
